-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement defer #12587
Implement defer #12587
Conversation
@jmooring does the API as outlined above make sense to you? |
I think the above is OK, but this caught my attention:
If that's the case, and if you anticipate that it will always be used this way, could we just have a defer block where the Not a big deal, but it may be easier to comprehend the intent. |
So, I thought about that, but
The first one is the deal breaker (unless we do string replacements), but the second bullet is also important (to me, anyhow). |
Yeah, I figured you did. LGTM. Things move fast in Hugo land. |
I assume you should not be able use |
No, that would not make sense. |
baa407b
to
2547c9d
Compare
A new feature coming in next Hugo. See gohugoio/hugo#12587
A new feature coming in next Hugo. See gohugoio/hugo#12587
A new feature coming in next Hugo. See gohugoio/hugo#12587
A new feature coming in next Hugo. See gohugoio/hugo#12587
A new feature coming in next Hugo. See gohugoio/hugo#12587
I must say that this works incredibly well with my new TailwindCSS setup in bep/hugo-starter-tailwind-basic#18 |
A new feature coming in next Hugo. See gohugoio/hugo#12587
A new feature coming in next Hugo. See gohugoio/hugo#12587
A new feature coming in next Hugo. See gohugoio/hugo#12587
A new feature coming in next Hugo. See gohugoio/hugo#12587
A new feature coming in next Hugo. See gohugoio/hugo#12587
A new feature coming in next Hugo. See gohugoio/hugo#12587
d17c2c1
to
37a4bbd
Compare
1744ac2
to
f657180
Compare
Closes gohugoio#8086 Closes gohugoio#12589
Closes #8086
My motivation for taking on this now is that I want to try to support JS code splitting, and that would need some more powerful "post build" synchronization than what we have today. This PR would eventually, I guess, replace
resources.PostProcess
. This PR needs more testing/polishing, but on the technical level this is simpler and without the many restrictions ofresources.PostProcess
.A typical use case for
resources.PostProcess
is TailwindCSS where we need to know the CSS classes etc. in use before we can build the CSS.Written using the new
defer
keyword, the TailwindCSS setup could look something like this:defer
only works withwith
key
: This is optional and can be thought about as being part of the cache key. In the example above, thedefer
block will be executed exactly once and then reused.data
: This becomes the "dot" in thedefer
block.Note that variables defined on the outside are not visible on the inside and vice versa. Any data must be passed in the
data
option, e.g.: